package com.czl.elm.controller;

import com.czl.elm.domain.*;
import com.czl.elm.service.IFoodService;
import com.czl.elm.service.IRedParperService;
import com.czl.elm.service.ISeckillService;
import com.czl.elm.service.IShopService;
import com.czl.elm.util.ActionResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping(value = "/test")
public class TestController {
    @Autowired
    private IShopService shopService;
    @Autowired
    private IFoodService foodService;
    @Autowired
    private IRedParperService redParperService;
    @Autowired
    private ISeckillService seckillService;

    @ApiOperation(value = "添加食物,暂时为测试用")
    @PostMapping("/addfood")
    public ActionResult addShopDetails( Food food){
        foodService.addFood(food);

        return ActionResult.success("获取成功");
    }

    @ApiOperation(value = "添加商店详情,暂时为测试用")
    @PostMapping("/addshop")
    public ActionResult addShopDetails(Shopdetails shopdetails){
        int res=shopService.addShopDetails(shopdetails);
        if(res==0){
            return ActionResult.error("没有该数据");
        }
        return ActionResult.success("获取成功");
    }

    @ApiOperation(value = "添加菜单中的菜,暂时为测试用")
    @PostMapping("/addmenu")
    public ActionResult addShopMenu(@RequestBody FoodMenu foodMenu){
        foodService.addShopMenu(foodMenu);

        return ActionResult.success("获取成功");
    }

    @ApiOperation(value = "添加商店优惠,暂时为测试用")
    @PostMapping("/addShopPreferential")
    public ActionResult addShopPreferential(@RequestBody ShopPreferential shopPreferential){
        shopService.t_addShopPreferential(shopPreferential);

        return ActionResult.success("获取成功");
    }

    @ApiOperation(value = "添加规格,暂时为测试用")
    @PostMapping("/addShopSpecifications")
    public ActionResult addFoodSpecifications(@RequestBody Map<String,Object> map){
        foodService.t_addShopSpecifications(map);

        return ActionResult.success("获取成功");
    }

    @ApiOperation("商家入住每日红包")
    @PostMapping("/addShopRedParper")
    public ActionResult addShopRedParper(@RequestBody Map<String,Object> msg){
        return redParperService.addShopRedParper(msg);
    }

    @ApiOperation("商家添加秒杀红包")
    @PostMapping("/addSeckillParper")
    public ActionResult addSeckillParper(@RequestBody Map<String,Object> msg){
        return seckillService.addSeckillParper(msg);
    }

    @ApiOperation("商家添加随机的菜谱")
    @PostMapping("/addRamdomFood")
    public ActionResult addRamdomFood(Integer shopId,Integer number){
        return shopService.t_addRamdomFood(shopId,number);
    }

    @ApiOperation("商家添加随机的食物菜单")
    @PostMapping("/addRamdomFoodMenu")
    public ActionResult addRamdomFoodMenu(Integer shopId){
        return shopService.t_addRamdomFoodMenu(shopId);
    }



}
